<?php

namespace plugins\yifang_backend_account\admin\controller;

use plugins\yifang_backend_account\controller\Base;

class Rbac_nav extends Base
{
    /**
     * 数据列表
     * @return mixed
     */
    public function index()
    {
        $paramsObj = paramsObj();
        $paramsObj->params = array(
            "format" => 1,
        );
        $response = app("YifangBackendAccount_C_Admin_rbacNav")->listData($paramsObj);
        $listData = array();
        if ($response["success"]) {
            $listData = $response["data"];
        }
        $data = array();
        $data["listData"] = $listData;
        $data["request"] = request()->param();
        return view("admin/rbac_nav/index", $data)->templatePath($this->templatePath);
    }

    /**
     * 添加
     * @return mixed
     */
    public function create()
    {
        $data = array();
        $data["request"] = request()->param();
        return view("admin/rbac_nav/create", $data)->templatePath($this->templatePath);
    }

    /**
     * 创建资源
     */
    public function store()
    {
        $result = app("YifangBackendAccount_C_Admin_rbacNav")->store();
        return jsonResponse($result);
    }

    /**
     * @actionName  编辑
     * @show 2
     */
    public function edit()
    {
        $result = app("YifangBackendAccount_C_Admin_rbacNav")->info();
        $rowData=array();
        if ($result["success"]) {
            $rowData = $result["data"];
        }
        $data = array();
        $data["rowData"] = $rowData;
        $data["request"] = request()->param();
        return view("admin/rbac_nav/edit", $data)->templatePath($this->templatePath);
    }

    /**
     * 更新资源
     */
    public function update()
    {
        $result = app("YifangBackendAccount_C_Admin_rbacNav")->update();
        return jsonResponse($result);
    }

    /**
     * 删除资源
     */
    public function delete()
    {
        $result = app("YifangBackendAccount_C_Admin_rbacNav")->delete();
        return jsonResponse($result);
    }
}